Skip to content

fix(ci): bound the narrowed test workers and their collection - #5614

Merged
dan-petty merged 3 commits into
mainfrom
fix/5606-narrowed-test-workers-fall-back-and
Nov 14, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/5606-narrowed-test-workers-fall-back-and

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The fix of #4472 counts the tests of a narrowed devops ci test run with a second pytest session, but three defects stopped it. syrupy made that collection exit 1 for the unused snapshots of a selected module, so the run went back to the file count. The run gave an explicit -n 4, and xdist does not bound that with PYTEST_XDIST_AUTO_NUM_WORKERS, so a runner pod with 1 CPU ran 4 workers. Each narrowed run also started the collection, with the 1800 s timeout of the run.

The collection now gives --snapshot-warn-unused. The worker cap is the smaller of 4 and PYTEST_XDIST_AUTO_NUM_WORKERS. A cap of 1 runs serially, and more than 50 target modules with no -k filter run on the cap. Both make no collection. The collection has its own timeout of 120 s, and its warning prints the command as text. The documents state the new rule.

Closes #5606

Change: openspec/changes/archive/2026-11-14-5606-narrowed-test-workers-fall-back-and/

The collection that counts the tests of a narrowed `devops ci test`
run exited 1 when a selected module had snapshots, because a
collection runs no test and syrupy found each snapshot unused. The run
then went back to the file count, so the 7 modules of #4472 still ran
with `-n 0`. The collection now gives `--snapshot-warn-unused`.

The run gave an explicit `-n 4`, which skips
`PYTEST_XDIST_AUTO_NUM_WORKERS`, so a runner pod with 1 CPU ran 4
workers. The run now starts at most the value of that variable, and a
bound of 1 runs serially with no collection. More than 50 target
modules with no `-k` filter also make no collection. The collection
has its own timeout of 120 s, and its warning prints as text.

On 1 CPU, a narrowed run of a 52-test module took 37 s before and 8 s
after.
The process fake now must receive DEFAULT_CI_TEST_COLLECTION_TIMEOUT_SECONDS
for the collection. The timeout case only read the reason text, so a
collection with the 1800 s timeout of the run passed it. The knowledge-base
page also names the second skip of the collection (#5606).
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/ci GitHub Actions workflows, pre-commit hooks, CI gates, and runners labels Nov 14, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results (local, head 6e21f7d on origin/main b15faab)

Real collection of the #4472 selection (7 modules):

  • On the base, uv run pytest -n 0 --collect-only -q <7 modules> printed 4 snapshots unused. and 422 tests collected, and exited 1. With --snapshot-warn-unused, it exited 0 and collected_items read 422 tests in 7.1 s.
  • On this branch, uv run devops ci test <7 modules> printed no collection warning and ran 4 workers [422 items]: 422 passed in 62.53s, 78 s end to end, exit 0.

Fail-to-pass: uv run devops ci fail-to-pass --base origin/main: 10 failed on base and 95 passed in tests/commands/test_test_selection.py, 0 errored. The failures on base are the new and changed cases of #5606, and test_the_full_gate_collects_every_test_module, which fails on the base only because the replay runs with -o addopts=. The CI Fail-to-Pass Check run is the proof of record.

Timing of one narrowed 52-test run (tests/roadmap/test_roadmap_claim.py, end to end, 16 CPUs on the host):

Run Before After
1 CPU, PYTEST_XDIST_AUTO_NUM_WORKERS=1 37.2 s, 37.7 s (collection, then -n 4) 8.6 s, 8.4 s (-n 0, no collection)
16 CPUs, variable not set 20.6 s, 20.9 s (collection, then -n 4) 22.3 s, 21.9 s (no change)

#5612 tracks the cost of 4 workers for a module of fast tests.

Scoped checks:

  • uv run devops ci --check --only lint,format,docs,constructs,openspec,test-settings,test-tree,startup-imports,swallowed-failures,domain: all pass.
  • uv run mypy on the 3 changed source files: no issues.
  • uv run devops ci test tests/commands/test_test_selection.py tests/commands/test_ci.py tests/commands/test_ci_repeat.py tests/ci/test_ci_gate_admission.py: 253 passed on 4 workers.
  • The builder ran the 166 target modules of the changed files: 5834 passed in 175 s, exit 0.

Review fix: the timeout case only read the reason text, so a collection with the 1800 s timeout of the run passed it. The new case test_the_collection_runs_under_its_own_short_timeout reads the timeout that the process fake receives. With the timeout reverted to DEFAULT_SUBPROCESS_TIMEOUT_SECONDS, it fails with assert (0, [1800.0]) == (0, [120.0]).

Render diff: the change touches no path under k8s/ and no chart values, so there is no render diff and no restart.

@dan-petty
dan-petty marked this pull request as ready for review November 14, 2026 03:56
@dan-petty
dan-petty merged commit 1430ab8 into main Nov 14, 2026
24 checks passed
@dan-petty
dan-petty deleted the fix/5606-narrowed-test-workers-fall-back-and branch November 14, 2026 04:00
dan-petty pushed a commit that referenced this pull request Nov 14, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.136.2](v0.136.1...v0.136.2)
(2026-11-14)


### Bug Fixes

* **ci:** bound the narrowed test workers and their collection
([#5614](#5614))
([1430ab8](1430ab8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/ci GitHub Actions workflows, pre-commit hooks, CI gates, and runners type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ci): narrowed test workers fall back and slow runs

1 participant